/**
 * Created by zzc on 2017/11/21
 */

'use strict'

import React, {Component} from 'react';

import {
    View,
    Text,
    Image,
    StyleSheet
} from 'react-native';


export default class HouseDetailTitle extends Component {

    constructor(props) {
        super(props)
        this.state = {
            response: "",
        }
    }

    render() {
        let info = this.state.response;
        let title = info.rentType == "SHARE" ? info.premName + " · " + info.roomNum : info.premName;
        let tagOne = info.rentType == "SHARE" ? "合租" : "整租";
        let tagTwo = "";
        if (info.apartmentType == "MANAGE") {
            tagTwo = "服务公寓";
        } else if (info.apartmentType == "BRAND") {
            tagTwo = "品牌公寓"
        } else {
            tagTwo = "服务公寓";
        }
        return (
            <View style={{flexDirection: "column", backgroundColor: "#F7F8FA"}}>
                <View style={styles.contain}>
                    <Text style={{fontSize: 18, color: "black"}}>{title}</Text>
                    <Text style={styles.price}>{info.price}<Text style={styles.h3s}>元/月</Text></Text>
                    <View style={{backgroundColor: "#F7F8FA", marginTop: 5, height: 1}}></View>
                    <View style={{flexDirection: "row", marginTop: 8}}>
                        <Text style={styles.tagTwo}>{tagTwo}</Text>
                        <Text style={styles.tagOne}>{tagOne}</Text>
                    </View>
                </View>
                <View style={{backgroundColor: "#F7F8FA", height: 10}}></View>

                {this._isRenderInstallment()}
            </View>

        );
    }

    _isRenderInstallment() {
       return this.state.response.cityCode == "0512"?(null):
            (<View style={{backgroundColor:"white",height:45,padding:10,alignItems:"center",flexDirection:"row"}}>

                <Image style={{width:25,height:12,resizeMode:"cover"}} source={require("../../../resource/images/icon_new3.png")}></Image>
                <Text style={{color:"black",fontSize:16,marginLeft:3}}>爱上租月付可分期</Text>

                <View style={{flex:1}}/>

                <View style={{flexDirection:"row",justifyContent:"flex-end",alignItems:"center"}}>

                    <Text style={{color:"#8F8E94",fontSize:14,marginRight:3}}>阅读须知</Text>
                    <Image style={{width:10,height:10,resizeMode:"cover"}} source={require("../../../resource/images/icon_right_arrow.png")}></Image>

                </View>

            </View>)

    }

    componentWillReceiveProps = (nextProps) => {
        this.setState({
            response: nextProps.item
        });
    }
}

const styles = StyleSheet.create({
    contain: {
        backgroundColor: 'white',
        flexDirection: "column",
        paddingTop: 10,
        paddingLeft: 10,
        paddingBottom: 10,
    },
    price: {
        fontSize: 15,
        color: '#FF3366',
        marginTop: 5
    },
    h3s: {
        fontSize: 10,
        color: '#FF3366',
    },
    tagOne: {
        fontSize: 10,
        color: '#33CFD9',
        borderWidth: 1,
        borderColor: '#33CFD9',
        borderRadius: 2,
        paddingLeft: 2,
        paddingRight: 2,
        textAlign: 'center',
        marginLeft: 3
    },
    tagTwo: {
        fontSize: 10,
        color: '#FDB73C',
        borderRadius: 2,
        borderWidth: 1,
        borderColor: '#FDB73C',
        paddingLeft: 2,
        paddingRight: 2,
        textAlign: 'center'
    },
});